package com.zy.web.demo.duoxiancheng.demo29;


import java.util.concurrent.locks.ReentrantLock;

/**
 * @author <a href="mailto:zhouyong@cqyyt.com">zy</a>
 * @version 1.0
 * @date 2020/8/31 16:09
 */
public class Service29 {

    private ReentrantLock lock;

    public Service29(Boolean zy){
        lock  = new ReentrantLock(zy);
    }

    public void service(){
        lock.lock();
        try {
            System.out.println("线程："+Thread.currentThread().getName()+"获得锁");
        }finally {
            lock.unlock();
        }
    }

}
